package cn.ggsaas.security.handler;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 登录成功 handler
 *
 * @author xuhongliang
 * @date 2020/5/25
 */
public class LoginSuccessHandler implements AuthenticationSuccessHandler {

	@Override
	public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
										Authentication authentication) throws IOException, ServletException {
		// 获取登录成功信息
		response.setContentType("application/json; charset=utf-8");
		response.getWriter().write("{\"code\": 200, \"msg\": \"登录成功\"}");
	}
}
